//
//  HomepageCell.m
//  HomeFinder
//
//  Created by lanou3g on 16/2/26.
//  Copyright © 2016年 蒋永昌. All rights reserved.
//

#import "HomepageCell.h"

#define kWidth self.contentView.bounds.size.width
#define kHeight self.contentView.bounds.size.height

@implementation HomepageCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addAllViews];
    }
    return self;
}
- (void)addAllViews
{
    self.pictureImage = [[UIImageView alloc]initWithFrame:CGRectMake(kWidth*0.05, kHeight*0.125, kWidth*0.35, kHeight*0.75)];
    self.pictureImage.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.pictureImage];
    
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.pictureImage.frame)+kWidth*0.05,CGRectGetMinY(self.pictureImage.frame), kWidth*0.5, kHeight*0.25)];
    self.titleLabel.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.titleLabel];
    self.districtLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.titleLabel.frame), CGRectGetMaxY(self.titleLabel.frame)+kHeight*0.1, kWidth*0.1, kHeight*0.125)];
    self.districtLabel.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.districtLabel];
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.districtLabel.frame)+kWidth*0.05,CGRectGetMinY(self.districtLabel.frame) , kWidth*0.35, kHeight*0.125)];
    self.nameLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.nameLabel];
    self.typeLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.titleLabel.frame), CGRectGetMaxY(self.districtLabel.frame)+kHeight*0.05, kWidth*0.15, kHeight*0.125)];
    self.typeLabel.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.typeLabel];
    self.areaLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.typeLabel.frame)+kWidth*0.05, CGRectGetMinY(self.typeLabel.frame), CGRectGetWidth(self.districtLabel.frame), CGRectGetHeight(self.districtLabel.frame))];
    self.areaLabel.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.areaLabel];
    self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.areaLabel.frame)+kWidth*0.1,CGRectGetMinY(self.areaLabel.frame), kWidth*0.1, kHeight*0.25)];
    self.priceLabel.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:self.priceLabel];
    
}
- (void)layoutSubviews
{
    self.pictureImage.frame = CGRectMake(kWidth*0.05, kHeight*0.125, kWidth*0.35, kHeight*0.75);
    self.titleLabel.frame = CGRectMake(CGRectGetMaxX(self.pictureImage.frame)+kWidth*0.05,CGRectGetMinY(self.pictureImage.frame), kWidth*0.5, kHeight*0.25);
    self.districtLabel.frame = CGRectMake(CGRectGetMinX(self.titleLabel.frame), CGRectGetMaxY(self.titleLabel.frame)+kHeight*0.1, kWidth*0.1, kHeight*0.125);
    self.nameLabel.frame = CGRectMake(CGRectGetMaxX(self.districtLabel.frame)+kWidth*0.05,CGRectGetMinY(self.districtLabel.frame) , kWidth*0.35, kHeight*0.125);
    self.typeLabel.frame = CGRectMake(CGRectGetMinX(self.titleLabel.frame), CGRectGetMaxY(self.districtLabel.frame)+kHeight*0.05, kWidth*0.15, kHeight*0.125);
    self.areaLabel.frame = CGRectMake(CGRectGetMaxX(self.typeLabel.frame)+kWidth*0.05, CGRectGetMinY(self.typeLabel.frame), CGRectGetWidth(self.districtLabel.frame), CGRectGetHeight(self.districtLabel.frame));
    self.priceLabel.frame = CGRectMake(CGRectGetMaxX(self.areaLabel.frame)+kWidth*0.1,CGRectGetMinY(self.areaLabel.frame) , kWidth*0.1, kHeight*0.25);
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
